/**
 * @file client_fun.h
 *
 * @author Federico Consoli
 *
 * Released under GNU GPLv3 (http://www.gnu.org/licenses/gpl-3.0.txt)
 */

#ifndef CLIENT_FUN_H
#define	CLIENT_FUN_H
#include "libreria.h"

using namespace std;

/** 
 * Implementation of the Fun class.
 * This class derive from the generic Client class.
 * It got the function to receive, store, send image or
 * rotate, flip image.
 *
 */
class Fun : public Client {
    /** List of local image */
    vector<string> list_of_jpg;

public:
    /**
     * Constructor
     * @param client_name Name of the client.
     * @param ip Ip of @link Registro register @endlink
     * @param porta Port of @link Registro register @endlink
     */
    Fun(string client_name = "CLIENT", string ip = "127.0.0.1", unsigned short porta = 40000);
    /**
     * Client menu
     */
    void menu();

    /**
     * Search in the local directory for some image and save the name in the
     * @link Fun::list_of_jpg @endlink vector.
     */
    void load_list_img();
    /**
     * Random function for the test
     */
    void random_fun();
    /**
     * Horizontal Flip image
     * @param name Name of the image to do the flip
     * @param sovrascrivi If set to 1 the function will rewrite the 
     * original image, if set to 0 it will rename it.
     * @throw Exception_class
     * - Exception Number 17: Unable to connect to the service provider; inconsistency of information.
     * @return -1 if the image is not found else return 0
     */
    int orizflip(string, int sovrascrivi = 1);

    /**
     * Rotate an image.
     * @param name Name of the image to do the rotate.
     * @param value Degree of rotation.
     * @param sovrascrivi If set to 1 the function will rewrite the 
     * original image, if set to 0 it will rename it.
     * @param crop_enable If crop is enable avoided the creation of images that are too big. 
     * it would cause the slowdown of the whole system
     * @throw Exception_class
     * - Exception Number 18: Unable to connect to the service provider; inconsistency of information.
     * @return -1 if the image is not found or degree are invalid else return 0
     */
    int rotate_img(string, int, int sovrascrivi = 1, int crop_enable = 0);

    /**
     * Send an image to the service provider
     * @param name Name of the image to store in the service providere
     * @throw Exception_class
     * - Exception Number 19: Unable to connect to the service provider; inconsistency of information.
     * @return -1 if the image is not found else return 0
     */
    int store_img(string);

    /**
     * Receive and save an image from the service provider
     * @param name Name of the image to receive.
     * @throw Exception_class
     * - Exception Number 20: Unable to connect to the service provider; inconsistency of information.
     * @return -1 if the image is not found else return 0
     */
    int get_img(string);

    /**
     * Get the image list from the service provider
     * @return string list
     */
    string get_list();
};


#endif	/* CLIENT_FUN_H */

